<template>
  <div style="text-align: center;">
    <n-list>
      <n-list-item>
        <h1>Hello Vue 3 + Vite</h1>
      </n-list-item>
      <n-list-item>
        <p>
          Recommended IDE setup:
          <a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
          +
          <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
        </p>
      </n-list-item>
      <n-list-item>
        <p>
          <a href="https://vitejs.dev/guide/features.html" target="_blank">
            Vite Documentation
          </a>
          |
          <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
        </p>
      </n-list-item>
      <n-list-item>
        <button type="button" @click="counter++">count is: {{ counter }}</button>
      </n-list-item>
      <n-list-item>
        <p>
          Edit
          <code>components/HelloWorld.vue</code> to test hot module replacement.
        </p>
      </n-list-item>
      <n-list-item>
        <div id="bind-attribute">
          <span v-bind:title="message">鼠标悬停几秒钟</span>
        </div>
      </n-list-item>
      <n-list-item>
        <div style="display: flex;flex-direction: column;justify-content: center">
          <n-gradient-text :size="24" type="warning">
            Theme
          </n-gradient-text>
          <n-switch :value="theme.darkTheme" :round="false" style="margin-top: 10px" @click="theme.switchTheme()">
            <template #checked>
              <n-icon size="14" color="#ffd93b">
                <sunny-sharp/>
              </n-icon>
            </template>
            <template #unchecked>
              <n-icon size="14" color="#ffd93b">
                <moon/>
              </n-icon>
            </template>
          </n-switch>
        </div>
      </n-list-item>
      <n-list-item>
        <div style="display: flex;flex-direction: column;justify-content: center">
          <n-gradient-text :size="24" type="warning">
            Other Theme
          </n-gradient-text>
          <div class="theme-color-list" style="margin-top: 10px">
            <span
                class="theme-item"
                v-for="(item, index) in theme.themeColorList"
                :key="index"
                :style="{ 'background-color': item }"
                @click="togTheme(item)"
            >
              <n-icon size="12" v-if="item === theme.themeColor">
                <check-outlined/>
              </n-icon>
            </span>
          </div>
        </div>
      </n-list-item>
      <n-list-item>
        <div style="display: flex;flex-direction: column;justify-content: center">
          <n-gradient-text :size="24" type="warning">
            Navigation Mode
          </n-gradient-text>
          <div class="nav-mode">
            <div v-for="mode in nvModeList" :key="mode" class="nav-mode-item">
              <div class="nav-type border-1px rounded-6px cursor-pointer" @click="togNavMode(mode)">
                <n-tooltip placement="bottom" trigger="hover">
                  <template #trigger>
                    <div class="nav-type-main relative w-56px h-48px bg-[#fff] rounded-4px overflow-hidden">
                      <div class="absolute-lt bg-[#273352]" :class="navModeMap.get(mode).menuClass"></div>
                      <div class="absolute-rb bg-[#f0f2f5]" :class="navModeMap.get(mode).mainClass"></div>
                    </div>
                  </template>
                  <span>{{ navModeLabelMap.get(mode) }}</span>
                </n-tooltip>
              </div>
              <n-badge dot color="#19be6b" :show="theme.navMode === mode" processing/>
            </div>
          </div>
        </div>
      </n-list-item>
      <n-list-item>
        <div style="display: flex;flex-direction: column;justify-content: center">
          <n-gradient-text :size="24" type="warning">
            Theme
          </n-gradient-text>
          <n-switch :value="!theme.crumbsConfig.visible" :round="false" style="margin-top: 10px" @click="theme.switchBreadcrumb()">
            <template #checked>
              <n-icon size="20" color="#ffd93b">
                <eye-show24-filled></eye-show24-filled>
              </n-icon>
            </template>
            <template #unchecked>
              <n-icon size="20" color="#ffd93b">
                <eye-hide24-filled></eye-hide24-filled>
              </n-icon>
            </template>
          </n-switch>
        </div>
      </n-list-item>
    </n-list>
  </div>
</template>

<script lang="ts" setup>
import {ref} from "vue";
import {NAV_MODE} from "@/enums/design_enum";
import type {FollowerPlacement} from 'vueuc';
import {designConfig} from "@/store";

const counter = ref(0)

const message = "You loaded this page on " + new Date().toLocaleDateString()

const theme = designConfig();

function togTheme(color: string) {
  theme.themeColor = color;
}

function togNavMode(mode: NAV_MODE) {
  theme.navMode = mode;
}

const nvModeList:NAV_MODE[] = [];
nvModeList.push(NAV_MODE.VERTICAL)

const navModeMap = new Map<NAV_MODE, { placement: FollowerPlacement; menuClass: string; mainClass: string }>([
  [NAV_MODE.VERTICAL, {placement: 'bottom', menuClass: 'w-1/3 h-full', mainClass: 'w-2/3 h-3/4'}],
  [NAV_MODE.HORIZONTAL, {placement: 'bottom', menuClass: 'w-full h-1/4', mainClass: 'w-full h-3/4'}],
  [NAV_MODE.HYBRID, {placement: 'bottom', menuClass: 'w-full h-1/4', mainClass: 'w-2/3 h-3/4'}]
]);

const navModeLabelMap = new Map<NAV_MODE, string>([
  [NAV_MODE.VERTICAL, "左侧菜单模式"],
  [NAV_MODE.HORIZONTAL, "顶部菜单模式"],
  [NAV_MODE.HYBRID, "左侧菜单混合模式"]
]);

</script>

<script lang="ts">
import {Moon, SunnySharp} from '@vicons/ionicons5';
import {EyeShow24Filled, EyeHide24Filled} from '@vicons/fluent';
import {CheckOutlined} from '@vicons/antd';

export default {
  name: "HelloWorld",
  components: {Moon, SunnySharp, CheckOutlined, EyeShow24Filled, EyeHide24Filled},
}
</script>

<style lang="less" scoped>
a {
  color: #42b983;
}

.theme-color-list {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;

  .theme-item {
    width: 20px;
    min-width: 20px;
    height: 20px;
    cursor: pointer;
    border-radius: 2px;
    margin: 0 5px 5px 0;
    text-align: center;

    .n-icon {
      color: #fff;
    }
  }
}

.nav-mode {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2px 0;

  &-item {
    display: inline-block;
    position: relative;
    margin-right: 16px;
    cursor: pointer;
    text-align: center;
  }

  img {
    width: 100%;
    height: 100%;
    display: block;
  }
}

</style>
